package cn.edu.ylu.gaoxin.utils;

import java.util.ArrayList;
import java.util.Iterator;

import cn.edu.ylu.gaoxin.model.Goods;
import cn.edu.ylu.gaoxin.model.Shop;
import cn.edu.ylu.gaoxin.model.ShopGoods;

/**
 * @author pangPython
 *
 */
public class DataUtils {

	//
	public static boolean ShopsGoods(){
		ArrayList<Goods> goodsList = Goods.dao.getAll();
		ArrayList<Shop> shopList  = (ArrayList<Shop>) Shop.dao.getAll();
		
		Iterator shopIt = shopList.iterator();
		Iterator goodsIt = goodsList.iterator();
		
        while(shopIt.hasNext()){
        	while(goodsIt.hasNext()){
        		ShopGoods sg = new ShopGoods();
        		sg.setGoodsId(((Goods)goodsIt.next()).getGoodsId());
        		sg.setShopId(((Shop)shopIt.next()).getShopId());
        		sg.save();
        	}
        }
		return true;
	}
	
	public static void main(String[] args){
		DataUtils.ShopsGoods();
	}
	
}
